unit upasservercocashdrawer;
{$I LogOption.txt}

interface
uses
  SysUtils,
  upasserverco,
  dom;

type
  EOupasservercocashdrawer = class(EOupasserverco)
  protected
    function doMethod(Node: TDOMNode): String; override;

    // CashDrawer Methods
    function OpenDrawer: Integer; virtual; abstract;
    function WaitForDrawerClose(BeepTimeout: Integer; BeepFrequency: Integer; BeepDuration: Integer; BeepDelay: Integer): Integer;  virtual; abstract;

    // CashDrawer Properties getter/setter
    function getCapStatus: WordBool; virtual; abstract;
    function getCapStatusMultiDrawerDetect: WordBool; virtual; abstract;
    function getDrawerOpened: WordBool; virtual; abstract;

    // CashDrawer Properties
    property CapStatus: WordBool read getCapStatus;
    property CapStatusMultiDrawerDetect: WordBool read getCapStatusMultiDrawerDetect;
    property DrawerOpened: WordBool read getDrawerOpened;

  end;

implementation
uses
  AuditLog,
  opos,
  upasxml;

function EOupasservercocashdrawer.doMethod(Node: TDOMNode): String;
var
  tmpS: String;
  tmpR: Integer;
begin
  Result := '';
  tmpR := 0;

  tmpS := Node.Attributes.Item[0].NodeValue;

  if tmpS = upasxml.xmltagOpenDrawer then begin
    tmpR := OpenDrawer;
    Result := 'Name' + '="' + tmpS + '" ' + 'Param0="' + IntToStr(tmpR) + '" ';
  end
  else if tmpS = upasxml.xmltagWaitForDrawerClose then begin
    tmpR := WaitForDrawerClose(
      StrToInt(Node.Attributes.Item[1].NodeValue),
      StrToInt(Node.Attributes.Item[2].NodeValue),
      StrToInt(Node.Attributes.Item[3].NodeValue),
      StrToInt(Node.Attributes.Item[4].NodeValue),
      );
    Result := 'Name' + '="' + tmpS + '" ' + 'Param0="' + IntToStr(tmpR) + '" ';
  end
  else
    Result := Inherited doMethod(Node);
end;

end.
